<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<title>添加管理员-权限管理-{$site.BACK_NAME}</title>
<include file="Public:jscss" />
</head>
<body>
<div class="wrap">
 <include file="Public:head"/>
 <div class="mainBody">
  <include file="Public:left"/>
  <div id="Right">
   <div class="contentArea">
    <div class="Item hr">
     <div class="current">添加管理员</div>
    </div>
    <form action="" method="post">
     <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
      <tr>
       <th width="120">账号邮件地址：</th>
       <td><input name="email" type="text" class="input" size="40" value="{$info.email}" /></td>
      </tr>
      <tr>
       <th>新密码：</th>
       <td><input class="input" name="pwd" type="password" size="40" value="" />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:red;">如果不修改请留空</span></td>
      </tr>
	  <tr>
       <th width="120">联系方式：</th>
       <td><input name="phone" type="text" class="input" size="40" value="{$info.phone}" /></td>
      </tr>
      <tr>
       <th>状态：</th>
       <td>
        <select name="status" style="width: 80px;">
		 <option value="1" {:is_selected($info['status'],1)}>启用</option>
         <option value="0" {:is_selected($info['status'],0)}>禁用</option>
        </select>
        如果禁用了将无法登陆本系统
	   </td>
      </tr>
	  <tr>
       <th width="120">姓名：</th>
       <td><input name="realname" type="text" class="input" size="40" value="{$info.realname}"/></td>
      </tr>
	  <tr>
       <th width="120">昵称：</th>
       <td><input name="nickname" type="text" class="input" size="40" value="{$info.nickname}" /></td>
      </tr>
      <tr>
       <th>所属用户组</th>
       <td>
		<select name="role_id" style="min-width: 80px;">
		 <foreach name="role_op" item="pr">
		 <option value="{$pr.id}" {:is_disabled($pr['status']==0, true)} {:is_selected($pr['id'],$info['role_id'])}>{$pr.fullname}</option>
		 </foreach>
		</select>
	   </td>
      </tr>
	  <tr>
       <th>直接上级</th>
       <td>
		<select name="boss_id" style="min-width: 80px;">
		 <option value="0">无直接上级</option>
		</select>
		&nbsp;&nbsp;&nbsp;选择所属用户组后才能进行直接上级选择
	   </td>
      </tr>
      <tr>
       <th>备注：</th>
       <td><textarea name="remark" rows="5" cols="57">{$info.remark}</textarea></td>
      </tr>
     </table>
     <input type="hidden" name="user_id" value="{$info.user_id}"/>
    </form>
    <div class="commonBtnArea">
     <button class="btn cfz_submit">提交</button>
    </div>
   </div>
  </div>
 </div>
</div>
<div class="clear"></div>
<include file="Public:foot"/>
<script type="text/javascript">
$(function(){
	var boss_json = {$boss_json};
	var role_pid = 0;
	var boss_id = {$info.boss_id};
	$("select[name='role_id']").change(function(){
		var rid = $("select[name='role_id']").val();
		$("select[name='boss_id'] option").remove();
		$("<option value='0'>无直接上级</option>").appendTo($("select[name='boss_id']"));
		//查找当前的role_pid
		$.each(boss_json, function(idx,item){
			if(item.role_id == rid){
				role_pid = item.role_pid;
				console.log("PID:"+role_pid);
				return false;
			}else{
				console.log("ID:"+item.role_id);
			}
		});
		//加入可用的上级管理员
		$.each(boss_json, function(idx,item){
			if(item.role_id == role_pid){
				if(boss_id == item.user_id){
					$("<option value='"+item.user_id+"' selected='selected'>"+item.realname+"</option>").appendTo($("select[name='boss_id']"));
				}else{
					$("<option value='"+item.user_id+"'>"+item.realname+"</option>").appendTo($("select[name='boss_id']"));
				}
			}
		});
	}).trigger("change");
	//提交表单
    $(".cfz_submit").click(function(){
        //if($.trim($("input[name='pwd']").val())==''){
		//	$.jBox.tip('密码不能为空', 'info');
        //    return false;
        //}
		commonAjaxSubmit();
    });
});
</script>
</body>
</html>